/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1610317401712_1208';

  // add your middleware config here
  config.middleware = [
    'errorHandler','auth','getuser'
  ];
  // 配置那些路由需要验证
config.auth = {
  // ignore: ['/reg', '/login'],
  match: [
    '/logout',
    '/video',
    '/video_detail',
    '/vod/sign',
    '/comment',
    '/fava',
    '/user/follow',
    '/user/unfollow',
    '/user/follows',
    '/user/fens',
    '/user/statistics',
    '/upload'
  ]
};

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
     // 跨域白名单
    domainWhiteList: [ 'http://localhost:8080' ],
  };
  // 允许跨域的方法
  config.cors = {
    origin: '*',
    allowMethods: 'GET, PUT, POST, DELETE, PATCH'
  };
  // sequelize 配置
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    username: "root",
    password: 'root',
    port: 3306,
    database: 'egg-video-demo',
    // 中国时区
    timezone: '+08:00',
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at
      timestamps: true,
      // 字段生成软删除时间戳 deleted_at
      // paranoid: true,
      createdAt: 'created_time',
      updatedAt: 'updated_time',
      // deletedAt: 'deleted_time',
      // 所有驼峰命名格式化
      underscored: true
    }
  };
  config.valparams = {
    locale    : 'zh-cn',
    throwError: true
};
config.crypto = {
  secret:  'kfdsoifeure98743984rjefy89dsy%^&%^&%jlkfjdiofysdfldskfjisdhfodhfpsdihp'
};
config.jwt = {
  secret: 'kfdsoifeure98743984rjefy89dsy%^&%^&%jlkfjdiofysdfldskfjisdhfodhfpsdihp'
};
config.redis = {
  client: {
      port: 6379,          // Redis port
      host: '127.0.0.1',   // Redis host
      password: '',
      db: 2,
  },
};
config.oss = {
  client: {
    accessKeyId: 'LTAI4Fy787o5yN2qvyssWtyu',
    accessKeySecret: 'NtvcFy6nDAEiilH2AU9MGwTuB8GF8c',
    bucket: 'disk-cloud-egg',
    endpoint: 'oss-cn-beijing.aliyuncs.com',
    timeout: '60s',
  },
};
config.multipart = {
  fileSize: '50mb',
  mode: 'stream',
  fileExtensions: ['.xls', '.txt', '.jpg', '.JPG', '.png', '.PNG', '.gif', '.GIF', '.jpeg', '.JPEG'], // 扩展几种上传的文件格式
};
// 腾讯云vod
config.tencentVod = {
  secret_id: "AKIDCAoHWUIhYBYHLOodz84i61mx1voTDTq0",
  secret_key: "4tTCbkfS9aryLepsmYv9DAwb6QYfG0Wn"
}
  return {
    ...config,
    ...userConfig,
  };
};
